clear

set more off


* Note: Analysis run using Stata MP 14.1

* Package Installations
*net install grc1leg, from( http://www.stata.com/users/vwiggins/) 

 
* Set working directory 
*Note: Make sure to update the directory to the location of the folder ("Mailhot. MIOM Data Replication. ISQ") on your computer

cd "/Users/cmailhot/Desktop/Mailhot. MIOM Data Replication. ISQ"

* Table 1

use "Table 1.dta"

export excel using "Table 1.xlsx", firstrow(variables) replace

clear


* Table 2

use "Table 2.dta"

export excel using "Table 2.xlsx", firstrow(variables) replace

clear

* Table 3

 
use "Table 3.dta"

export excel using "Table 3.xlsx", firstrow(variables) replace

clear


* Figure 1

use "Figure 1.dta"



graph bar IOSumMandatePoliceRef IOSumMandateHR IOSumMandateCeaseFire IOSumMandateCivilAdminReform IOSumMandateMediaReform IOSumMandateMilitaryReform if IntlOrganization == "UN",  title("UN") blabel(total) saving("Components of Figure 1/UN.gph", replace)

graph bar IOSumMandatePoliceRef IOSumMandateHR IOSumMandateCeaseFire IOSumMandateCivilAdminReform IOSumMandateMediaReform IOSumMandateMilitaryReform if IntlOrganization == "AU",  title("AU") blabel(total) saving("Components of Figure 1/AU.gph", replace) 

graph bar IOSumMandatePoliceRef IOSumMandateHR IOSumMandateCeaseFire IOSumMandateCivilAdminReform IOSumMandateMediaReform IOSumMandateMilitaryReform if IntlOrganization == "OSCE",  title("OSCE") blabel(total) saving("Components of Figure 1/OSCE.gph", replace) 

graph bar IOSumMandatePoliceRef IOSumMandateHR IOSumMandateCeaseFire IOSumMandateCivilAdminReform IOSumMandateMediaReform IOSumMandateMilitaryReform if IntlOrganization == "NATO",  title("NATO") blabel(total) saving("Components of Figure 1/NATO.gph", replace) 

graph bar IOSumMandatePoliceRef IOSumMandateHR IOSumMandateCeaseFire IOSumMandateCivilAdminReform IOSumMandateMediaReform IOSumMandateMilitaryReform if IntlOrganization == "EU",  title("EU") blabel(total) saving("Components of Figure 1/EU.gph", replace) 

graph bar IOSumMandatePoliceRef IOSumMandateHR IOSumMandateCeaseFire IOSumMandateCivilAdminReform IOSumMandateMediaReform IOSumMandateMilitaryReform if IntlOrganization == "OAS",  title("OAS") blabel(total) saving("Components of Figure 1/OAS.gph", replace) 


grc1leg "Components of Figure 1/UN.gph" "Components of Figure 1/AU.gph" "Components of Figure 1/EU.gph" "Components of Figure 1/NATO.gph" "Components of Figure 1/OAS.gph" "Components of Figure 1/OSCE.gph", play("Figure 1 partial.grec")
graph save Graph "Components of Figure 1/Figure 1 Partial.gph", replace

graph use "Components of Figure 1/Figure 1 Partial.gph", play("Figure 1 full.grec")
graph save Graph "Figure 1.gph", replace

clear

* Figure 2

use "Figure 2.dta"


graph bar CeasefirePercent ChildrensRightsPercent DisarmPercent ElectionPercent JudicialPercent PolicePercent, blabel(total) bargap(10) play("Figure 2.grec")
graph save Graph "Figure 2.gph", replace

clear


* Figure 3

use "Figure 3.dta"

line WomensRightsYearlyProp MandateResYear || line ChildrensRightsYearlyProp MandateResYear ||  line MilitaryReformYearlyProp MandateResYear ||  line EconSocDevYearlyProp MandateResYear ||  line ExecReformYearlyProp MandateResYear ||  line MediaReformYearlyProp MandateResYear , play("Figure 3.grec")
graph save Graph "Figure 3.gph", replace

clear





* Figure 4 and Table B1 (Appendix)

use "Replication_Data_for_Built-in_Safeguards. With MIOM Data_Subsetted.dta"


*Labeling Variables
label variable agg_imp_rate_woe "Accord Implementation Rate (0-100)"
label variable powtran_implem "Powershairng government (0-3)"
label variable dispute_implem "Dispute Resolution Mechanism (0-3)"
label variable verify_implem "Verification Mechanism (0-3)"
label variable donor_implem  "Donor Support (0-3)"
label variable unpkf_implem "Agreement UN/Regional Mission(0-3)"
label variable roa_implem  "Review of Agreement (0-3)"
label variable total_prov_woe "Number of Provisions"
label variable ex_constrain5_7 "Executive Constraints"
label variable conflict_type "Conflict Type (1 = Territorial)"
label variable infant_rate "Infant Mortality Rate"
label variable gdppc_currus_1000 "GDP Per Capita in 1000s (2005 USD)"
label variable year_count "Year Count"
label variable con_conflict "Post Accord Conflict"
label variable war_dur "War Duration (months)"
label variable total_dead "Total Dead"
label variable meanprov "Difference in Number of Agreement Provisions"
label variable PropProvisionsWithEnforcement "Proportion of Provisions with Mandated Enforcement (MIOM)"
label variable ProportionLevelofInvolve "Proportion Level of Mandated Enforcement (MIOM)"

*Define Data as Time Series Data
xtset caseid year_count


*replication: Proportion of provisions with mandated enforcement

estimates clear

xtgls agg_imp_rate_woe verify_implem  powtran_implem dispute_implem donor_implem  unpkf_implem roa_implem  meanprov  ex_constrain5_7 conflict_type infant_rate gdppc_currus_1000    year_count  if exclude_case !=1, corr(psar1)
eststo replication

xtgls agg_imp_rate_woe l.agg_imp_rate_woe PropProvisionsWithEnforcement powtran_implem dispute_implem donor_implem  roa_implem  meanprov ex_constrain5_7 conflict_type infant_rate   year_count gdppc_currus_1000 
eststo propenforcextreglag

xtgls agg_imp_rate_woe l.agg_imp_rate_woe ProportionLevelofInvolve powtran_implem dispute_implem donor_implem  roa_implem  meanprov  ex_constrain5_7 conflict_type infant_rate  year_count gdppc_currus_1000 
eststo levelofinvolvextreglag

* Figure 4
coefplot (replication, keep(verify_implem unpkf_implem)) (propenforcextreglag, keep(PropProvisionsWithEnforcement)) (levelofinvolvextreglag, keep(ProportionLevelofInvolve)), play("Figure 4.grec")

* Results for Figure 4 in appendix
esttab replication propenforcextreglag levelofinvolvextreglag using TableB1Appendix.rtf, star(* 0.05 ** 0.01 *** 0.001) b(2) se(2) stats(N aic r2 p) label noconstant replace

clear


* Figure A1 in Appendix (comparison of activities in UNPMM nad MIOM)

use "Comparison of UNPMM and MIOM.dta"

graph bar UNPMMMeanActivitiesByMission MIOMMeanActivitiesByMission if mission_abbrev == "UNMIL",  title("UNMIL") blabel(total) saving("Components of Figure A2/UNMIL.gph", replace)

graph bar UNPMMMeanActivitiesByMission MIOMMeanActivitiesByMission if mission_abbrev == "UNTAES",  title("UNTAES") blabel(total) saving("Components of Figure A2/UNTAES.gph", replace)

graph bar UNPMMMeanActivitiesByMission MIOMMeanActivitiesByMission if mission_abbrev == "UNAMA",  title("UNAMA") blabel(total) saving("Components of Figure A2/UNAMA.gph", replace)

graph bar UNPMMMeanActivitiesByMission MIOMMeanActivitiesByMission if mission_abbrev == "ONUSAL",  title("ONUSAL") blabel(total) saving("Components of Figure A2/ONUSAL.gph", replace)

graph bar UNPMMMeanActivitiesByMission MIOMMeanActivitiesByMission if mission_abbrev == "UNTAC",  title("UNTAC") blabel(total) saving("Components of Figure A2/UNTAC.gph", replace)

grc1leg "Components of Figure A2/UNMIL" "Components of Figure A2/UNTAES" "Components of Figure A2/UNAMA" "Components of Figure A2/ONUSAL" "Components of Figure A2/UNTAC", play("Components of Figure A2/Figure A2 in Appendix partial.grec")
graph save Graph "Components of Figure A2/Figure A2 Partial.gph", replace

graph use "Components of Figure A2/Figure A2 Partial.gph", play("Figure A2 full.grec")
graph save Graph "Figure A2.gph", replace


clear



